/*
 * Copyright (C), 2020, 安徽艾伦家居饰品有限公司
 * FileName: AuthUserControllerImpl
 * Author:   Allen
 * Date:     2020/8/15
 * Description: 获取用户信息
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.haoyu.auth.rest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 获取用户信息
 *
 * @author Allen
 * @date 2020-07-10
 */
@ApiIgnore
@RestController
@RequestMapping("/oauth")
public class UserLogoutController {

    /**
     * 注入tokenServices
     */
    @Autowired
    ConsumerTokenServices tokenServices;

    /**
     * 用户登出
     * @param accessToken Token值
     * @return 是否成功标识
     */
    @GetMapping(value = "/logout", produces = {MediaType.APPLICATION_JSON_VALUE})
    public Boolean revokeToken(@RequestParam(value = "accessToken") String accessToken) {
        return tokenServices.revokeToken(accessToken);
    }
}
